package com.samebuilding.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateHelper {
	public static String getDateStr(Date date, String format) {
		DateFormat df = new SimpleDateFormat(format);
		String dateStr = df.format(date);
		return dateStr;
	}

	public static Date getDate(String dateStr, String format) 
	throws Exception {
		DateFormat df = new SimpleDateFormat(format);
		Date date = df.parse(dateStr);
		return date;
	}
	public static Date madeDate() throws ParseException{
			Calendar date=Calendar.getInstance();
			int year=date.get(Calendar.YEAR);
			int month=date.get(Calendar.MONTH)+1;
			int day=date.get(Calendar.DAY_OF_MONTH);
			int hour=date.get(Calendar.HOUR_OF_DAY);
			int min=date.get(Calendar.MINUTE);
		    int sec=date.get(Calendar.SECOND);
			String time=year+"-"+month+"-"+day+" "+hour+":"+min+":"+sec;
			
			
			DateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
			Date d = df.parse(time);
			return d;
	}
}
